The present invention relates generally to a computer graphics system, and, more particularly, to graphics device drivers.
A typical computer graphics system comprises a graphics adapter providing a frame buffer and graphics acceleration hardware, together with a software device driver providing an interface between the graphics adapter hardware and the operating system (OS) and/or application software running on top of the operating system. The graphics adapter serves to facilitate a display of elaborate graphics while relieving the computer's central processing unit (CPU) of computational responsibility for graphics processing, and improving overall performance.
A device driver, often called a driver for short, is a computer program that enables another program, typically an OS, to interact with a hardware device. In a Windows OS environment, when an application calls a Win32 function with device-independent graphics requests, the Graphics Device Interface (GDI) interprets these instructions and calls the display driver. The display driver then translates these requests into commands for the video hardware to draw graphics on the screen.
A shader is a program used in 3D computer graphics to describe the traits of either a vertex or a pixel. With shader programs, seemingly complicated surfaces can be rendered from simple geometry. For example, a shader can be used to draw a grid of 3D ceramic tiles from a simple plane.
Vertex shaders describe the traits (position, texture coordinates, colors, etc.) of a vertex, while pixel shaders describe the traits (color, z depth and alpha value) of a pixel.
Pixel shaders often have to be “driven” by the vertex shaders. For example, to calculate per-pixel lighting, a pixel shader needs the orientation of a triangle, the orientation of a light vector and in some cases the orientation of a view vector. The output rate of the pixel shader determines the performance of the GPU as a pixel shader at a later stage than the vertex shader in a 3D pipeline.
The most rendered image requires cooperation of the vertex shader and the pixel shader. If the vertex shader load is higher than the pixel shader load, the pixel shader has to wait for the vertex shader, which will reduce the pixel shader's output rate. So balancing the loading of the vertex shader and pixel shader is an effective way to increase performance.
Traditionally, both vertex and pixel shader programs run on dedicated graphics processing units (GPUs) in the graphics adapter. In a multi-Core CPU system with multi-thread capability, a graphics driver can direct an idle CPU thread to do a software vertex shader. But before the software vertex shader finishes, the driver is still held up and cannot issue subsequent commands to GPUs, which may cause GPU idling.
Another issue with using the software vertex shader is a so called z-fighting, which is caused by greater precision in z-depth. For example, in a 16-bit z-buffer, the z-value can be any integer number between 0 and 65535 (216). Software vertex shader and GPU hardware vertex shader may have different resolution. If a first vertex is processed by a software vertex shader and an adjacent second vertex with the same z-value as the first vertex is processed by a hardware vertex shader with a different resolution, then z-values of the first and second vertex after the vertex shader transformation becomes different, which is not acceptable.
Meanwhile the x and y value do not have such precision issues, as shader transformed values of x and y are limited by a display screen size, which is not larger than 2048 and is much smaller than even a 16-bit z-buffers 65535. Besides, the origin of both the x and y axes is at the center of the display screen, so their resolution requirements are further reduced by one half.
It is therefore desirable for a driver on one hand, to allow multi-Core CPU to be able to share some vertex shader computational load, on the other hand still to be able to maintain uniform z-values after shader transformation, and at the same time maximizing both CPU and GPU utilization through command buffering.